home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-05 | 4.4 KB | 165 lines | [TEXT/KAHL] |
- //____________________________________________________________
- // FileMenu.c
- //
- // Copyright © Dan Parks Sydow, 1995
- // From the book:
- // "Graphics and Sound Programming Techniques for the Mac",
- // M&T Books, 1995
-
-
- //____________________________________________________________
-
- #include <Movies.h>
-
- #include "Defines.h"
- #include "DataTypes.h"
- #include "Globals.h"
- #include "WindRecordAccess.h"
- #include "MovieUtilities.h"
- #include "FileMenu.h"
-
-
- //____________________________________________________________
-
- void HandleFileMenuOpenItem( void )
- {
- SFTypeList typeList = { MovieFileType, 0, 0, 0 };
- StandardFileReply theReply;
- OSErr theError;
- short theFileRefNum;
- Movie theMovie;
- short theMovieResID = 0;
- Str255 theMovieResName;
- Boolean wasAltered;
- WindowPtr theWindow;
- Ptr theWindowStorage;
- Rect theMovieBox;
- Rect theBoundsRect;
- MovieController theController;
-
- StandardGetFilePreview( nil, 1, typeList, &theReply );
-
- if ( theReply.sfGood == false )
- return;
-
- theError = OpenMovieFile( &theReply.sfFile, &theFileRefNum, fsRdWrPerm );
- if ( theError != noErr )
- ExitToShell();
-
- theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
- theMovieResName, newMovieActive, &wasAltered );
- if ( theError != noErr )
- ExitToShell();
-
- theWindowStorage = NewPtr( sizeof ( BigWindRecord ) );
- theWindow = GetNewCWindow( rMovieWindow, theWindowStorage, (WindowPtr)-1L );
-
- SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );
-
- GetMovieBox( theMovie, &theMovieBox );
-
- theController = NewMovieController( theMovie, &theMovieBox, mcTopLeftMovie);
-
- MCSetActionFilterWithRefCon( theController,
- NewMCActionFilterWithRefConProc( SizeChangeMCActionFilter ),
- (long)theWindow );
-
- MCGetControllerBoundsRect( theController, &theBoundsRect );
-
- SizeWindow( theWindow, theBoundsRect.right, theBoundsRect.bottom, true );
- ShowWindow( theWindow );
-
- MCEnableEditing( theController, true );
-
- SetWindowType( theWindow, kMovieWindowType );
- SetWindowMovie( theWindow, theMovie );
- SetWindowController( theWindow, theController );
- SetWindowFileReference( theWindow, theFileRefNum );
- SetWindowMovieResourceID( theWindow, theMovieResID );
-
- ++gWindowCount;
- }
-
-
- //____________________________________________________________
-
- void HandleFileMenuCloseItem( void )
- {
- WindowPtr theWindow;
-
- theWindow = FrontWindow();
- CloseMovieAndFile( theWindow );
- }
-
-
- //____________________________________________________________
-
- void HandleFileMenuSaveItem( void )
- {
- WindowPtr theWindow;
- Movie theMovie;
- short theFileRefNum;
- short theMovieResID;
-
- theWindow = FrontWindow();
-
- if ( GetWindowType( theWindow ) == kMovieWindowType )
- {
- theMovie = GetWindowMovie( theWindow);
- theFileRefNum = GetWindowFileReference( theWindow );
- theMovieResID = GetWindowMovieResourceID( theWindow );
- UpdateMovieResource( theMovie, theFileRefNum, theMovieResID, nil );
- }
- }
-
- //____________________________________________________________
-
- void HandleFileMenuSaveAsItem( void )
- {
- StandardFileReply theReply;
- WindowPtr theWindow;
- Movie theMovie;
-
- StandardPutFile( "\pSave as:", "\pUntitled", &theReply );
-
- if ( theReply.sfGood == false )
- return;
-
- theWindow = FrontWindow();
-
- theMovie = GetWindowMovie( theWindow );
-
- FlattenMovie( theMovie, flattenAddMovieToDataFork,
- &theReply.sfFile, 'TVOD', 0,
- createMovieFileDeleteCurFile, nil, nil );
-
- SetWTitle( theWindow, theReply.sfFile.name );
- }
-
-
- //____________________________________________________________
-
- void HandleFileMenuQuitItem( void )
- {
- int i;
- int theNumWindows;
- WindowPtr theWindow;
- WindowPeek theWindPeek;
- WindowPtr theNextWindow;
-
- theNumWindows = gWindowCount;
- theWindow = FrontWindow();
-
- for (i = 0; i < theNumWindows; i++)
- {
- theWindPeek = ((WindowPeek)theWindow)->nextWindow;
- theNextWindow = (WindowPtr)theWindPeek;
- if ( GetWindowType( theWindow ) == kMovieWindowType )
- CloseMovieAndFile( theWindow );
- theWindow = theNextWindow;
- }
- gDone = true;
- }
-
-
-